window.onload =function () {

    findByItem(1);
}
let channelId = getQuery("id")

function skip() {
    location.href="/addPost.html?id="+channelId;
}
function findByItem(pageNO) {

    axios.get("/post/findByItem",{
        params:{
            pageNO,
            channelId,
            theme:$("title").value,
            userName:$("author").value,
            startDate:$("startDate").value,
            endDate:$("endDate").value
        }
    }).then(resp=>{
        let info = resp.data;
       let str = "";
        info.records.forEach(n=>{
            str += `<tr>
                <td><a href="/reply.html?postId=${n.id}">${n.theme}</a></td>
                <td>${n.userBean.username}</td>
                <td>${n.replyCount}</td>
                <td>${n.createDate}</td>
            </tr>`
            console.log(n.id)
        })
        console.log(resp.data)

        $("data").innerHTML=str;

        let cutStr="";
        for (let i = 1; i <=info.pages ; i++) {
                cutStr +=`<a href="javascript:findByItem(${i})" style="margin-left: 10px">${i}</a>`
        }
        $("cutDiv").innerHTML=cutStr;

    })
}